package com.ruoyi.user.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.support.Convert;
import com.ruoyi.user.domain.Knowledge;
import com.ruoyi.user.mapper.KnowledgeMapper;

/**
 * 健康知识 服务层实现
 * 
 * @author ruoyi
 * @date 2018-12-18
 */
@Service
public class KnowledgeServiceImpl implements IKnowledgeService 
{
	@Autowired
	private KnowledgeMapper knowledgeMapper;

	/**
     * 查询健康知识信息
     * 
     * @param id 健康知识ID
     * @return 健康知识信息
     */
    @Override
	public Knowledge selectKnowledgeById(Integer id)
	{
	    return knowledgeMapper.selectKnowledgeById(id);
	}
	
	/**
     * 查询健康知识列表
     * 
     * @param knowledge 健康知识信息
     * @return 健康知识集合
     */
	@Override
	public List<Knowledge> selectKnowledgeList(Knowledge knowledge)
	{
	    return knowledgeMapper.selectKnowledgeList(knowledge);
	}
	
    /**
     * 新增健康知识
     * 
     * @param knowledge 健康知识信息
     * @return 结果
     */
	@Override
	public int insertKnowledge(Knowledge knowledge)
	{
	    return knowledgeMapper.insertKnowledge(knowledge);
	}
	
	/**
     * 修改健康知识
     * 
     * @param knowledge 健康知识信息
     * @return 结果
     */
	@Override
	public int updateKnowledge(Knowledge knowledge)
	{
	    return knowledgeMapper.updateKnowledge(knowledge);
	}

	/**
     * 删除健康知识对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteKnowledgeByIds(String ids)
	{
		return knowledgeMapper.deleteKnowledgeByIds(Convert.toStrArray(ids));
	}

	@Override
	public List<Knowledge> selectKnowledgeListByParam(String dataId, String pageSize) {
		if (Integer.parseInt(dataId) == 0) {
			return knowledgeMapper.selectKnowledgeListByParams(Integer.parseInt(pageSize));
		}else{
			return knowledgeMapper.selectKnowledgeListByParamd(Integer.parseInt(dataId),Integer.parseInt(pageSize));
		}
		
	}
	
}
